package io.dbw.common.filter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
　* @description: 小程序登录拦截
　* @author lxc
　* @date 2021/9/29 15:15
*/
@Configuration
@Order(2)
public class MinorAppLoginFilter implements WebMvcConfigurer {
    /**
     * 这里需要先将限流拦截器入住，不然无法获取到拦截器中的redisUtil
     * @return
     */
    @Bean
    public AuthorityInterceptor getAuthorityInterceptor() {
        return new AuthorityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 拦截器按照顺序执行,如果不同拦截器拦截存在相同的URL，前面的拦截器会执行，后面的拦截器将不执行
         */
        registry.addInterceptor(getAuthorityInterceptor());
    }
}
